package com.yh.chapter1.pojo;

/**
 * @ClassName Man
 * @Description TODO
 * @Author 0715-YuHao
 * @Date 2020/11/4 10:11
 */
public class Man extends Person{
    private String sex;

    static {
        System.out.println("我是静态代码块子");
    }

    public Man() {
        System.out.println("我是Man");
    }

    public Man(String name, int age, String sex) {
        super(name, age);
        this.sex = sex;
    }

    public Man(String name, int age) {
        super(name, age);
    }

    public Man getInstance(String name, int age, String sex) {
        return new Man(name, age);
    }

    @Override
    public boolean equals(Object o) {
        if (!super.equals(o)) return false;
        if (!(o instanceof Man)) return false;
        Man man = (Man) o;
        return sex.equals(man.sex);
    }

    @Override
    public int hashCode() {
        int result = super.hashCode();
        result = 31 * result + (sex != null ? sex.hashCode() : 0);
        return result;
    }
}
